home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 7: Programming / CDAT7.iso / demos / VisualAge for Java 2.0 Entry / setup / data1.cab / ide-e / IDE / cache / FFZ0MJ (.txt) < prev    next >
Encoding:
Java Class File  |  1998-09-16  |  2.2 KB  |  57 lines

  1. package com.sun.java.swing.plaf.basic;
  2.  
  3. import com.sun.java.swing.ComboBoxEditor;
  4. import com.sun.java.swing.JTextField;
  5. import com.sun.java.swing.border.Border;
  6. import java.awt.Component;
  7. import java.awt.event.ActionListener;
  8. import java.awt.event.FocusEvent;
  9. import java.awt.event.FocusListener;
  10. import java.io.Serializable;
  11.  
  12. public class BasicComboBoxEditor implements ComboBoxEditor, FocusListener, Serializable {
  13.    protected JTextField editor = new BorderlessTextField("", 9);
  14.  
  15.    public BasicComboBoxEditor() {
  16.       this.editor.addFocusListener(this);
  17.       this.editor.setBorder((Border)null);
  18.    }
  19.  
  20.    public void addActionListener(ActionListener l) {
  21.       this.editor.addActionListener(l);
  22.    }
  23.  
  24.    public void focusGained(FocusEvent e) {
  25.    }
  26.  
  27.    public void focusLost(FocusEvent e) {
  28.       this.editor.postActionEvent();
  29.    }
  30.  
  31.    public Component getEditorComponent() {
  32.       return this.editor;
  33.    }
  34.  
  35.    public Object getItem() {
  36.       return this.editor.getText();
  37.    }
  38.  
  39.    public void removeActionListener(ActionListener l) {
  40.       this.editor.removeActionListener(l);
  41.    }
  42.  
  43.    public void selectAll() {
  44.       this.editor.selectAll();
  45.       this.editor.requestFocus();
  46.    }
  47.  
  48.    public void setItem(Object anObject) {
  49.       if (anObject != null) {
  50.          this.editor.setText(anObject.toString());
  51.       } else {
  52.          this.editor.setText("");
  53.       }
  54.  
  55.    }
  56. }
  57.